package section7;

import java.util.Arrays;

public class sixth {
	public static void main(String[] args) {
		int arr[] = {1,2,3,4,5,6,7,8,9,0,3,2,4,5,6,7,4,32,2,1,1,4,6,3};
		int count=-1;
		for (int i = 0; i < arr.length; i++) {
			for (int j = 0; j < arr.length; j++) {
				if(i==j||arr[i]==0) {
					continue;
				}else if(arr[i]==arr[j]) {
					arr[j]=0;
				}
			}
		}
		for (int i = 0; i < arr.length; i++) {
			if(arr[i]==0) {
				count++;
				for (int j = i+1; j < arr.length; j++) {
					if(arr[j]!=0) {
						arr[i]=arr[j];
						arr[j]=0;
						break;
					}
				}
			}
		}
		int newArr[] = Arrays.copyOf(arr, arr.length-count+1);
		System.out.println(Arrays.toString(arr));
		System.out.println(Arrays.toString(newArr));
	}
}
